/* app-window.c
 *
 * Copyright 2023 wan-iot
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "app-config.h"
#include "app-window.h"



struct _AppWindow
{
  GtkApplicationWindow  parent_instance;

  /* Template widgets */
  GtkHeaderBar        *header_bar;
  GtkButton *my_btn;
};

G_DEFINE_TYPE (AppWindow, app_window, GTK_TYPE_APPLICATION_WINDOW)

static void
app_window_class_init (AppWindowClass *klass)
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

  gtk_widget_class_set_template_from_resource (widget_class, "/a/b/c/app-window.ui");
  gtk_widget_class_bind_template_child (widget_class, AppWindow, header_bar);
 gtk_widget_class_bind_template_child (widget_class, AppWindow, my_btn);
  g_print("aaa==\n");

}
const GtkHeaderBar *bar;

void ok(GtkButton* btn,gpointer data){
  g_print("okok==\n");
  g_print("%s\n",gtk_button_get_label (btn));
  gtk_header_bar_set_title (bar, (char*)data );

}



static void
app_window_init (AppWindow *self)
{
  gtk_widget_init_template (GTK_WIDGET (self));

  g_print("bbb==\n");
  bar = self->header_bar;
  //gtk_button_get
  g_signal_connect(self->my_btn, "clicked", G_CALLBACK (ok), "hello,app!");

}
